export default class DepartureVerificationCodeUtil {
  static checkCodeV2(tag: string): boolean {
    if (tag === null || tag === '' || tag.length < 2) {
      return false
    }
    const num = parseInt(tag, 10)
    if (isNaN(num) || num <= 100) {
      return false
    }
    const tagLength = tag.length
    const lastChar = parseInt(tag.charAt(tagLength - 1), 10)
    const temStr = tag.substring(0, tagLength - 1)
    let tempSum = 0
    for (let i = 0; i < temStr.length; i++) {
      const charNum = parseInt(temStr.charAt(i), 10)
      tempSum += charNum * 3
    }
    const sumStr = String(tempSum)
    const lastSumChar = parseInt(sumStr.charAt(sumStr.length - 1), 10)
    return lastChar === lastSumChar
  }
}
